<?php
final class ABConf{
	private static $a_config;
	public static function load($s_filename='config'){
		$s_file = $s_filename;
		$s_filename = PATH_ABS."/config/$s_filename.json";
		if(!is_file($s_filename)) throw new ABException('The path not is a file');
		self::$a_config[$s_file] = json_decode(file_get_contents($s_filename), true);
		if(empty(self::$a_config)) throw new ABException('File of configuration not Valid');
	}
	
	public static function get($s_key, $s_file = 'config'){
		return self::$a_config[$s_file][$s_key];
	}

	public static function getAll($s_file = 'config'){
		return self::$a_config[$s_file];
	}
	public static function save($s_filename){
		$r_file = fopen($s_filename,'w');
		if(fwrite($r_file, json_encode(self::$a_config[$s_filename]))){
			fclose($r_file);
			return true;
		}
		fclose($r_file);
		return false;
	}
}
?>
